package com.hbnu.net;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class TcpServerDemo3 {
    public static void main(String[] args) {
        try {
            ServerSocket serverSocket = new ServerSocket(9999);

            Socket socket = serverSocket.accept();

            BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            BufferedWriter out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));

            String line = null;
            while ((line = in.readLine()) != null) {
                line = line.toLowerCase();      //转大写

                out.write(line);        //将转换后的数据返回给客户端
                out.newLine();      //发送一个换行，否则消息不合适
                out.flush();
            }


        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
}
